import Storage from '@/utils/Storage'
import { TableEnum, ThemeEnum } from '@/enums/ElementUIEnum'

const state = {
  size: 'medium',
  headerCellStyle: {
    textAlign: 'center',
    backgroundColor: '#F5F7FA'
  }
}

const getters = {
  getSize (state) {
    state.size = Storage.get(ThemeEnum.SIZE) || state.size
    return state.size
  },
  getHeaderCellStyle (state) {
    state.headerCellStyle = Storage.get(TableEnum.HEADER_CELL_STYLE) || state.headerCellStyle
    return state.headerCellStyle
  }
}

const mutations = {
  setSize (state, value) {
    Storage.set(ThemeEnum.SIZE, value)
    state.size = value
  },
  setHeaderCellStyle (state, value) {
    Storage.set(TableEnum.HEADER_CELL_STYLE, value)
    state.headerCellStyle = value
  },
}

const actions = {}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
  actions,
}
